package com.flca.frw.util
{
	import com.flca.frw.model.ExceptionInfo;
	
	import flash.events.Event;
	
	import mx.controls.Alert;
	import mx.managers.CursorManager;
	import mx.rpc.events.FaultEvent;
	
	public class FaultHandler
	{
		public function FaultHandler()
		{
		}

		public static function handleFault(aEvent:FaultEvent):void 
		{
			CursorManager.removeBusyCursor();
			
			var info:ExceptionInfo;
			var message:String;
			
			if (ExceptionUtil.isApplicationException(aEvent.fault))
			{
				info = ExceptionUtil.parseFault(aEvent.fault);
				message = info.message;
//				message = ExceptionUtil.translateExceptionInfo(info, Configuration.getInstance().getServerMessagesXml());
			}
			else
			{
				message = "Unknown error occured:\n\n" + aEvent.fault.faultDetail;
			}
			
			//timeoutFlag = ExceptionUtil.determineIfCodeIsPresent(info, "E0002")
			//              || ExceptionUtil.determineIfCodeIsPresent(info, "E0003");
			
			Alert.show(message, "Error occurred ...", Alert.OK, null, handleAlertOk);
		}

		private static function handleAlertOk(aEvent:Event):void
		{
		}

	}
}